var gamePageController = (function() {

    var GameField = Class.create({
        init: function(holder, positionX, positionY) {
            this._holder = holder;
            this._positionX = positionX;
            this._positionY = positionY;
        },
        create: function() {
            var gameConteiner = $('<div/>');

            gameConteiner.css('width', '598px');
            gameConteiner.css('height', '588px');
            gameConteiner.attr('class', 'boardFiled');
            var gameField = $('<div/>');
            gameField.attr('id', 'gameField');
            $(this._holder).append(gameConteiner.append(gameField));
        }
    });

    var Menu = Class.create({
        init: function(firstButtonText, secondButtonText, holder) {
            this._holder = holder;
            this._fButton = firstButtonText;
            this._sButton = secondButtonText;
        },
        create: function() {
            var ul = $('<ul/>');
            ul.attr('id', 'menu');
            
            var firstLi = $('<li/>');
            var firstA = $('<a/>');
            firstA.text(this._fButton);
            
            var secondLi = $('<li/>');
            var secondA = $('<a/>');
            secondA.text(this._sButton);

            firstLi.append(firstA);
            ul.append(firstLi);
            secondLi.append(secondA);
            ul.append(secondLi);

            var menuHolder = $('<div/>');
            menuHolder.attr('id', 'menuHolder');
            menuHolder.append(ul);

            $(this._holder).append(menuHolder);
        }
    });

    var ScoreBoard = Class.create({
        init: function () {
            this.Points = localStorage.getItem("score");
			
        },
        create: function () {
            var scoreWrapper = $("#score");
            scoreWrapper.html(this.Points);
        }
    });

    return {
        GameField: function(holder, positionX, positionY) {
            return new GameField(holder, positionX, positionY);
        },
        Menu: function(firstButtonText, secondButtonText, holder) {
            return new Menu(firstButtonText, secondButtonText, holder);
        },
        ScoreBoard: function () {
            return new ScoreBoard();
        }
    };
})();

gamePageController.GameField('#wrapper', 100, 100);
var gridView = gamePageController.GameField('#wrapper', 100, 100);
gridView.create();
var menu = gamePageController.Menu('Main menu', 'Quit', '#wrapper');
var scoreBoard = gamePageController.ScoreBoard();
scoreBoard.create();
menu.create();